package com.stone.design.mode.pipeline.netty.context;

import com.stone.design.mode.pipeline.netty.handler.ChannelHandler;
import com.stone.design.mode.pipeline.netty.pipeline.DefaultChannelPipeline;

import java.util.concurrent.Executor;

/**
 * 默认的context实现
 *
 * @author wenpan 2024/01/21 17:51
 */
public final class DefaultChannelHandlerContext extends AbstractChannelHandlerContext {

    /**
     * 该context包裹的handler
     */
    private final ChannelHandler handler;

    public DefaultChannelHandlerContext(DefaultChannelPipeline pipeline,
                                 Executor executor,
                                 String name,
                                 ChannelHandler handler) {
        super(name, pipeline, executor, handler.getClass());
        // 该context包含的handler
        this.handler = handler;
    }

    @Override
    public ChannelHandler handler() {
        return handler;
    }

}
